package org.linphone.sub.treeview;

import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import org.linphone.R;

import me.texy.treeview.TreeNode;
import me.texy.treeview.base.BaseNodeViewBinder;

/**
 * Created by Xiang on 2018/5/15.
 */

public class AllList extends BaseNodeViewBinder {
	//箭头图标
	private ImageView image_arrow;
	//名称
	private TextView all_name;
	//初始化数据
	public AllList(View itemView) {
		super(itemView);
		image_arrow = (ImageView) itemView.findViewById(R.id.image_arrow);
		all_name = (TextView) itemView.findViewById(R.id.all_name);
	}
	//获取数据Id
	@Override
	public int getLayoutId() {
		return R.layout.all_item;
	}
	//绑定View
	@Override
	public void bindView(TreeNode treeNode) {
		String[] all = treeNode.getValue().toString().split("[$]");
		all_name.setText(all[0]);
	}
	//图标切换
	@Override
	public void onNodeToggled(TreeNode treeNode, boolean expand) {
		if(expand){
			image_arrow.setImageResource(R.mipmap.img_catergory_spinner_icon);
		}else {
			image_arrow.setImageResource(R.mipmap.img_catergory_icon);
		}
	}

}
